import java.time.DayOfWeek;
import java.time.LocalDate;

public class LocalDateTest {
    public static void main(String[] args) {
        // 获取本地日期对象（不可变对象）
        LocalDate ld = LocalDate.now();  // 年月日
        System.out.println(ld);

        // 获取日期中的信息
        int year = ld.getYear();          //获取年
        int month = ld.getMonthValue();   //获取月
        int day = ld.getDayOfMonth();     //获取日
        int Day_Year = ld.getDayOfYear();  //获取一年中的第几天
        int DayOfWeek = ld.getDayOfWeek().getValue();//获取星期几

        System.out.println(year);
        System.out.println(month);
        System.out.println(day);
        System.out.println(Day_Year);
        System.out.println(DayOfWeek);

        // 直接修改某个信息 with
        LocalDate ld2 = ld.withYear(2099);
        LocalDate ld3 = ld.withMonth(12);
        System.out.println(ld);
        System.out.println(ld2);
        System.out.println(ld3);

        // 把某个信息加多少 plus
        LocalDate NewYear = ld.plusYears(100);
        LocalDate NewMonth = ld.plusMonths(3);
        System.out.println(NewYear);
        System.out.println(ld);

        // 把某个信息减多少 minus
        LocalDate NewYear2 = ld.minusYears(100);
        System.out.println(NewYear2);

        // 获取指定日期的LocalDate对象
        LocalDate localDate = LocalDate.of(2300, 12, 31);
        LocalDate localDate1 = LocalDate.of(2300, 12, 31);
        System.out.println(localDate);

        // 判断两个日期对象是否相等,在前还是在后   equals   isBefore   isAfter
        System.out.println(localDate.equals(localDate1));
        System.out.println(localDate.isAfter(ld));    //localDate时间是否在当前时间之后
        System.out.println(localDate.isBefore(ld));   //localDate时间是否在当前时间之前

    }
}
